<!-- 修改密码 -->
<template>
    <div>
        <el-card style="width:50%">
            <el-form :model="form">
                <el-form-item prop="password" label="原密码" :label-width="formLabelWidth">
                    <el-input v-model="form.password" type="password" show-password />
                </el-form-item>
                <el-form-item prop="newPassword" label="新密码" :label-width="formLabelWidth">
                    <el-input v-model="form.newPassword" type="password" show-password />
                </el-form-item>
                <el-form-item prop="renewPassword" label="确认密码" :label-width="formLabelWidth">
                    <el-input v-model="form.renewPassword" type="password" show-password />
                </el-form-item>
                <el-form-item :label-width="formLabelWidth">
                    <el-button type="primary" @click="handler">确认修改</el-button>
                </el-form-item>
            </el-form>
        </el-card>
    </div>
</template>

<script setup lang="ts">
import { ElMessage } from 'element-plus';
import { reactive } from 'vue';
import { reqUpdatePassword } from '../../api/user';
import { passwordData } from '../../api/user/type';
const formLabelWidth = '70px'
let form = reactive<passwordData>({
    password: '',
    newPassword: '',
    renewPassword: ''
})

const handler = async () => {
    let result: any = await reqUpdatePassword(form)
    if (result.code == 20000) {
        ElMessage.success('密码修改成功')
    } else {
        ElMessage.error(result.msg)
    }
}
</script>

<style lang="scss" scoped>
.el-form {
    padding: 20px 30px;

    .el-button {
        margin: 0 auto;
    }
}
</style>